$(function () {
    var permission_datagrid = $("#permission_datagrid");
    permission_datagrid.datagrid({
        url: '/permission/query.do',
        fit: true,
        fitColumns: true,
        columns: [[
            {field: 'name', title: '权限名称', width: 100,},
            {field: 'resource', title: '权限表达式', width: 100,}
        ]],
        singleSelect: true,
        pagination: true,
        toolbar: "#permission_btns",
    });
    var methodObj = {
        loadPermission: function () {
            $.get('/permission/loadPermission.do',function (data) {
                if (data.success) {
                    $.messager.alert('温馨提示', '加载成功', 'info')
                    permission_datagrid.datagrid('reload');
                } else {
                    $.messager.alert('温馨提示', data.msg, 'error');
                }
            });
        },
        reload:function () {
            permission_datagrid.datagrid('load');
        }
    }
    $("a[data-cmd]").click(function () {
        var methodName = $(this).data('cmd');
        methodObj[methodName]();
    })
})



